<template>
	<p :style="_style">
		<Link
			:underline="false"
			type="primary"
			@click="onClickLink"
		>
			{{content}}
		</Link>
	</p>
</template>
<script>
import {Link} from 'element-ui';
export default {
	name:'McLink',
	components:{
		Link,
	},
	props:{
		textStyle:{
			type:Object,
			default: () => ({
				'text-align':'left',
			}),
		},
		content:{
			type:String,
			default:'链接',
		},
		href:{
			type:String,
			default:'',
		},
		target:{
			type:String,
			default:'_self',
		},
	},
	computed:{
		_style(){
			return {...this.textStyle};
		},
	},
	methods:{
		onClickLink(event){
			this.$emit('click', event);
			if(!this.href) return;
			if(this.target === '_self'){
                // this.$router.push({
                //     path: `/externalLink?href=${encodeURIComponent(Base64.encode(this.href))}`,
                // });
				this.$router.push({
					path:`/externalLink?href=${this.href}`,
				});
			}else if(this.target === '_blank'){
				window.open(this.href, this.target);
			}
		},
	},
};
</script>